<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<#include "../../base/_meta.html"> 
<@head>

<script type="text/javascript">
// temp function

//reload table
function doSearch(){
	doSearchG1();
	doSearchG2();
}

function doSearchG1(){
	var name1=$("#xm1").val();
	g1.set({url:"/ddesign/project/mumbers?projectcode=${(pro.projectcode)!}&displayname="+name1});
	g1.reload();
}
function doSearchG2(){
	var name2=$("#xm2").val();
	g2.set({url:"/ddesign/project/users?projectcode=${(pro.projectcode)!}&displayname="+name2});
	g2.reload();
}
// init liger ui 
$(function (){
  	 window['g1'] =
     $("#maingrid1").ligerGrid({
   	  columns: [
           { display: '已配人员', name: 'displayname',  width: 110, minWidth: 60 },
           { display: '操作', name: 'loginaccount',  width: 95, minWidth: 20,render: f_renderMove }
           ], url: '/ddesign/project/mumbers?projectcode=${(pro.projectcode)!}',
           pageSize: 10,   
           height: '98%',width: 210,
           toolbar: { items: [
				       	{ text: '姓名', type:"textbox", id:'xm1',name:'xm1',size:13 },
				        { text: '查询',click: doSearchG1, icon: 'search' }]}

     });
     window['g2'] =
     $("#maingrid2").ligerGrid({
   	 columns: [
        { display: '人员姓名', name: 'displayname',  width: 110, minWidth: 60 },
        { display: '操作', name: 'loginaccount',  width: 95, minWidth: 20,render: f_renderAdd }
        ], url: '/ddesign/project/users?projectcode=${(pro.projectcode)!}',
        pageSize: 10,        
        height: '98%',width: 210,
        toolbar: { items: [
   				       	{ text: '姓名', type:"textbox", id:'xm2',name:'xm2',size:13 },
   				        { text: '查询',click: doSearchG2, icon: 'search' }]}
    });

     $("#pageloading").hide();
    //人员配置超链接
    function f_renderAdd(rowdata, index, value){
    	//var a = "<img src='/asserts/images/icons/plus.gif' style='cursor:pointer' onclick='configMumber(\""+rowdata.projectcode+"\")' alt='点击配置'/><a href='javascript:addMumber(\""+rowdata.loginaccount+"\")'>添加</>";
    	var a = "<a href='javascript:addMumber(\""+rowdata.loginaccount+"\")'>添加</>";
    	return a;
    }
  	//人员配置超链接
    function f_renderMove(rowdata, index, value){
    	//var a = "<img src='/asserts/images/icons/candle.gif' style='cursor:pointer' onclick='removeMumber(\""+rowdata.loginaccount+"\")' alt='点击移除'/><a href='javascript:removeMumber(\""+rowdata.loginaccount+"\")'>移除</>";
    	var a = "<a href='javascript:removeMumber(\""+rowdata.loginaccount+"\")'>移除</>";
    	return a;
    }
    $("#pageloading").hide();
});
function addMumber(loginaccount){
	var projectcode = $("#projectcode").val();
	$.ajax({
		url:"/ddesign/project/addMumber?loginaccount="+loginaccount+"&projectcode="+ projectcode,
		success:function(msg){
        	if(msg >= 1){
        		$.ligerDialog.success('成功添加 '+ msg + ' 用户，下次登陆后生效。');
        		doSearch();
        	}else{
        		$.ligerDialog.error('添加用户失败。') 
        	}
    	}
	});
}
function removeMumber(loginaccount){
	var projectcode = $("#projectcode").val();
	$.ajax({
		url:"/ddesign/project/removeMumber?loginaccount="+loginaccount+"&projectcode="+ projectcode,
		success:function(msg){
        	if(msg >= 1){
        		$.ligerDialog.success('成功移除 '+ msg + ' 条用户，下次登陆后生效。');
        		doSearch();
        	}else{
        		$.ligerDialog.error('移除用户失败。') 
        	}
    	}
	});
}
</script>
</@head>
<body style="overflow-x: hidden; padding: 2px;">
	<div id="searchbar"> 项目名称:${(pro.projectname)!}</div>
	<input type="hidden" name="projectcode" id="projectcode" value="${(pro.projectcode)!}"/>
	<div id="maingrid1" style="margin: 4px; padding: 0; float: left;"></div>
    <div id="maingrid2" style="margin: 4px; padding: 0; margin-left: 10px; float: left;"></div>
</body>
</html>